package com.example.udpDemo.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * Description: 传感器状态枚举
 *
 * @author sjt Administrator
 * @since 2023/12/3 16:00
 */
@Getter
@AllArgsConstructor
public enum GasStatusEnum {
    NORMAL(0x00, "正常", "NORMAL"),
    FAULT_LOWER_LIMIT(0x01, "故障下限值", "float"),
    FAULT_UPPER_LIMIT(0x02, "故障上限值", "float"),
    LOW_LIMIT_ALARM(0x03, "低限报警", "float"),
    HIGH_LIMIT_ALARM(0x04, "高限报警", "float"),
    ALARM_START(0x05, "报警器启动", "00000000"),
    ALARM_STOP(0x06, "报警器停止", "FFFFFFFF");

    private final int code;
    private final String chineseName;
    private final String gasType;


    public static GasStatusEnum getByCode(int code) {
        return Arrays.stream(GasStatusEnum.values()).filter(v -> code == v.getCode()).findFirst().orElse(null);
    }
}

